package com.growthgate.bootcommon.entity;

import com.growthgate.bootcommon.annotation.UpdateNullable;
import com.growthgate.bootcommon.common.base.BaseEntity;
import com.growthgate.bootcommon.entity.enums.Sex;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.Column;
import javax.persistence.Entity;
import java.io.Serializable;
import java.util.Date;

/**
 * 用户
 *
 * @author GrowthGate
 * @date 2019/10/28
 */
@Data
@Entity
@ApiModel
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class User extends BaseEntity implements Serializable {

    private static final long serialVersionUID = -5361398411208372060L;

    @ApiModelProperty("id")
    private Long id;

    @CreatedDate
    @ApiModelProperty("创建时间")
    private Date createTime;

    @LastModifiedDate
    @ApiModelProperty("修改时间")
    private Date updateTime;

    /**
     * 用户名
     */
    @Column(nullable = false, length = 20)
    @ApiModelProperty("用户名")
    private String username;

    /**
     * 密码
     */
    @Column(nullable = false, length = 32)
    @ApiModelProperty("密码")
    private String password;

    /**
     * 昵称
     */
    @Column(length = 50)
    @ApiModelProperty("昵称")
    private String nickname;

    /**
     * 性别
     */
    @ApiModelProperty("性别")
    private Sex sex;

    /**
     * 年龄
     */
    @UpdateNullable
    @ApiModelProperty("年龄")
    private Integer age;

}